package com.twetec.cms.dao.mapper.statistic;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.twetec.cms.model.po.statistic.StatisticSitePageViewsPO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ZCZ
 * @since 2022-03-05
 */
public interface StatisticSitePageViewsMapper extends BaseMapper<StatisticSitePageViewsPO> {

    @Select("SELECT\n" +
            "  STATISTIC_SITE_PAGE_VIEWS.SITE_ID,WEBSITE_SITE.NAME AS SITE_NAME,\n" +
            "\tSUM( STATISTIC_SITE_PAGE_VIEWS.SITE_HOME_VIEWS_COUNT ) AS SITE_HOME_VIEWS_COUNT,\n" +
            "\tSUM( STATISTIC_SITE_PAGE_VIEWS.ARTICLE_VIEWS_COUNT ) AS ARTICLE_VIEWS_COUNT,\n" +
            "\tSUM( STATISTIC_SITE_PAGE_VIEWS.COLUMN_HOME_VIEWS_COUNT ) AS COLUMN_HOME_VIEWS_COUNT\n" +
            "FROM\n" +
            "\tSTATISTIC_SITE_PAGE_VIEWS\n" +
            "\tLEFT JOIN WEBSITE_SITE ON STATISTIC_SITE_PAGE_VIEWS.SITE_ID = WEBSITE_SITE.ID " +
            " ${ew.customSqlSegment}  \n" +
            "\tGROUP BY STATISTIC_SITE_PAGE_VIEWS.SITE_ID,WEBSITE_SITE.NAME")
    public List<StatisticSitePageViewsPO> pageViewCount(@Param(Constants.WRAPPER) QueryWrapper<StatisticSitePageViewsPO> queryWrapper);
}
